#!/bin/bash
#
# ==========================================================
GA_HOME=/share/apps/ga
GA_BUILD=${GA_HOME}/build
GA_CLASSDIR=${GA_BUILD}/classes
JGAP_CLASSDIR=${GA_BUILD}/classes/jgap
GA_WORKDIR=${GA_HOME}/work
JGAP_SRCTOP=${GA_WORKDIR}/src/jgap-src
JGAP_SRCREALTOP=${JGAP_SRCTOP}/org/jgap
JGAP_EXAMPLESTOP=${JGAP_SRCTOP}/jgap-examples
JGAP_TESTSRCTOP=${JGAP_SRCTOP}/jgap-tests/org/jgap
LIBROOT=${GA_HOME}/lib
JGAP_LIB=${LIBROOT}/jgap

JAVAC=${JAVA_HOME}/bin/javac
JAR=${JAVA_HOME}/bin/jar

#${JGAP_SRCREALTOP}/distr/sockets/*.java

SOURCES="${JGAP_SRCREALTOP}/*.java \
${JGAP_SRCREALTOP}/audit/*.java \
${JGAP_SRCREALTOP}/data/*.java \
${JGAP_SRCREALTOP}/data/config/*.java \
${JGAP_SRCREALTOP}/distr/*.java \
${JGAP_SRCREALTOP}/distr/grid/*.java \
${JGAP_SRCREALTOP}/distr/grid/common/*.java \
${JGAP_SRCREALTOP}/distr/grid/gp/*.java \
${JGAP_SRCREALTOP}/distr/grid/request/*.java \
${JGAP_SRCREALTOP}/distr/grid/util/*.java \
${JGAP_SRCREALTOP}/distr/grid/wan/*.java \
${JGAP_SRCREALTOP}/eval/*.java \
${JGAP_SRCREALTOP}/event/*.java \
${JGAP_SRCREALTOP}/gp/*.java \
${JGAP_SRCREALTOP}/gp/function/*.java \
${JGAP_SRCREALTOP}/gp/function/statistics/*.java \
${JGAP_SRCREALTOP}/gp/impl/*.java \
${JGAP_SRCREALTOP}/gp/terminal/*.java \
${JGAP_SRCREALTOP}/gui/*.java \
${JGAP_SRCREALTOP}/impl/*.java \
${JGAP_SRCREALTOP}/impl/job/*.java \
${JGAP_SRCREALTOP}/impl/fitness/*.java \
${JGAP_SRCREALTOP}/impl/salesman/*.java \
${JGAP_SRCREALTOP}/supergenes/*.java \
${JGAP_SRCREALTOP}/util/*.java \
${JGAP_SRCREALTOP}/util/tree/*.java \
${JGAP_SRCREALTOP}/xml/*.java"

#${JGAP_EXAMPLESTOP}/gp/monalisa/*.java \
EXAMPLESRC="${JGAP_EXAMPLESTOP}/*.java \
${JGAP_EXAMPLESTOP}/audit/*.java \
${JGAP_EXAMPLESTOP}/chromInit/*.java \
${JGAP_EXAMPLESTOP}/config/*.java \
${JGAP_EXAMPLESTOP}/distinctGenes/*.java \
${JGAP_EXAMPLESTOP}/dynamicMutation/*.java \
${JGAP_EXAMPLESTOP}/energy/*.java \
${JGAP_EXAMPLESTOP}/equalDistribution/*.java \
${JGAP_EXAMPLESTOP}/functionFinder/*.java \
${JGAP_EXAMPLESTOP}/functionFinder/test/*.java \
${JGAP_EXAMPLESTOP}/gp/*.java \
${JGAP_EXAMPLESTOP}/gp/anttrail/*.java \
${JGAP_EXAMPLESTOP}/gp/monalisa/core/*.java \
${JGAP_EXAMPLESTOP}/gp/monalisa/core/commands/*.java \
${JGAP_EXAMPLESTOP}/gp/monalisa/gui/*.java \
${JGAP_EXAMPLESTOP}/gp/paintedDesert/*.java \
${JGAP_EXAMPLESTOP}/gp/tictactoe/*.java \
${JGAP_EXAMPLESTOP}/grid/evolutionDistributed/*.java \
${JGAP_EXAMPLESTOP}/grid/fitnessDistributed/*.java \
${JGAP_EXAMPLESTOP}/grid/mathProblemDistributed/*.java \
${JGAP_EXAMPLESTOP}/knapsack/*.java \
${JGAP_EXAMPLESTOP}/math/*.java \
${JGAP_EXAMPLESTOP}/math/cmd/*.java \
${JGAP_EXAMPLESTOP}/math/ga/*.java \
${JGAP_EXAMPLESTOP}/monalisa/core/*.java \
${JGAP_EXAMPLESTOP}/monalisa/gui/*.java \
${JGAP_EXAMPLESTOP}/multidimension/*.java \
${JGAP_EXAMPLESTOP}/multiobjective/*.java \
${JGAP_EXAMPLESTOP}/salesman/*.java \
${JGAP_EXAMPLESTOP}/simpleBoolean/*.java \
${JGAP_EXAMPLESTOP}/simpleBooleanThreaded/*.java \
${JGAP_EXAMPLESTOP}/supergene/*.java"

TESTSOURCE="${JGAP_TESTSRCTOP}/*.java \
${JGAP_TESTSRCTOP}/audit/*.java \
${JGAP_TESTSRCTOP}/data/*.java \
${JGAP_TESTSRCTOP}/data/config/*.java \
${JGAP_TESTSRCTOP}/distr/*.java \
${JGAP_TESTSRCTOP}/distr/grid/*.java \
${JGAP_TESTSRCTOP}/eval/*.java \
${JGAP_TESTSRCTOP}/event/*.java \
${JGAP_TESTSRCTOP}/ext/*.java \
${JGAP_TESTSRCTOP}/gp/*.java \
${JGAP_TESTSRCTOP}/gp/function/*.java \
${JGAP_TESTSRCTOP}/gp/impl/*.java \
${JGAP_TESTSRCTOP}/gui/*.java \
${JGAP_TESTSRCTOP}/impl/*.java \
${JGAP_TESTSRCTOP}/impl/fitness/*.java \
${JGAP_TESTSRCTOP}/impl/job/*.java \
${JGAP_TESTSRCTOP}/impl/salesman/*.java \
${JGAP_TESTSRCTOP}/perf/*.java \
${JGAP_TESTSRCTOP}/supergenes/*.java \
${JGAP_TESTSRCTOP}/util/*.java \
${JGAP_TESTSRCTOP}/xml/*.java"

# ==========================================================
CP="${JGAP_LIB}/appframework-1.0.3.jar:\
${JGAP_LIB}/commons-cli-1.0.jar:\
${JGAP_LIB}/commons-codec-1.3.jar:\
${JGAP_LIB}/commons-lang-2.1.jar:\
${JGAP_LIB}/jcgrid.jar:\
${JGAP_LIB}/jcommon-1.0.14.jar:\
${JGAP_LIB}/jeksparser.jar:\
${JGAP_LIB}/jfreechart-1.0.11.jar:\
${JGAP_LIB}/junit3.8.1.jar:\
${JGAP_LIB}/junit-addons-1.4.jar:\
${JGAP_LIB}/log4j.jar:\
${JGAP_LIB}/swing-layout-1.0.3.jar:\
${JGAP_LIB}/swing-worker-1.1.jar:\
${JGAP_LIB}/TableLayout.jar:\
${JGAP_LIB}/trove-2.0.2.jar:\
${JGAP_LIB}/xpp3_min-1.1.3.4.O.jar:\
${JGAP_LIB}/commons-math-2.0.jar:\
${JGAP_LIB}/colt.jar:\
${JGAP_LIB}/concurrent.jar:\
${JGAP_LIB}/commons-math-2.0.jar:\
${JGAP_LIB}/xstream-1.2.2.jar"
#${JGAP_LIB}/jgap-tests.jar:\
#${JGAP_LIB}/jgap-examples.jar:\



echo "${JAVAC} -d ${JGAP_CLASSDIR} -classpath ${CP} -nowarn ${SOURCES} ${EXAMPLESRC} ${TESTSOURCE}"
${JAVAC} -d ${JGAP_CLASSDIR} -classpath ${CP} -nowarn ${SOURCES} ${EXAMPLESRC} ${TESTSOURCE} 

#echo "${JAVAC} -d ${JGAP_CLASSDIR} -classpath ${CP} -nowarn ${EXAMPLESRC}"
#${JAVAC} -d ${JGAP_CLASSDIR} -classpath ${CP} -nowarn ${EXAMPLESRC} 

echo "${JAR} -cf ${LIBROOT}/jgap.jar -C ${JGAP_CLASSDIR} org -C ${JGAP_CLASSDIR} examples"
${JAR} -cf ${LIBROOT}/jgap.jar -C ${JGAP_CLASSDIR} org -C ${JGAP_CLASSDIR} examples
